package com.briup.day16;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * @author 谭梦寻
 * @version 1.1
 * 对象反序列化
 */
public class TestReadObject {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
//        1 声明流 创建流对象
        FileInputStream fis = new FileInputStream("obj.txt");
        ObjectInputStream ois = new ObjectInputStream(fis);
//        2 操作流：读操作
        Object o = ois.readObject();
        System.out.println(o);
        System.out.println(o instanceof Student);
        Student jack = (Student)o;//向下转型
        jack.getId();
//        3 关闭流
        ois.close();
    }
}
